package com.qdevelop.control.bean;

import java.util.Map;

public class UrlPatternBean {
	@SuppressWarnings("unchecked")
	public UrlPatternBean(Map data){
		urlPattern = (String)data.get("URLPATTERN");
		rid = (String)data.get("RID");
		gid = (String)data.get("GID");
		uid = (String)data.get("UID");
	}
	private String urlPattern;
	private String rid;
	private String gid;
	private String uid;
	
	public String getUrlPattern() {
		return urlPattern;
	}
	public void setUrlPattern(String urlPattern) {
		this.urlPattern = urlPattern;
	}
	public String getRid() {
		return rid;
	}
	public void setRid(String rid) {
		this.rid = rid;
	}
	public String getGid() {
		return gid;
	}
	public void setGid(String gid) {
		this.gid = gid;
	}
	
	public void addRoleId(String rids){
		rid += ";"+rids;
		gid = null;
	}
	
	public String getUid() {
		return uid;
	}
	public void setUid(String uid) {
		this.uid = uid;
	}
	public String getPatternRid(){
		
//		if(rid.indexOf(";")>-1){
//			rid = rid.replaceAll(";;", ";").trim();
//			if(rid.startsWith(";")){
//				rid = rid.substring(1);
//			}
//			if(rid.endsWith(";")){
//				rid = rid.substring(0,rid.length()-1);
//			}
//			rid = rid.replaceAll(";", "|");
//		}
		if(rid==null)return "-1";
		if(rid.indexOf(";")>-1){
			rid = rid.trim().replaceAll(";+", "|").replaceAll("^\\|+|\\|+$", "");
		}
		return rid;
	}
	
}
